<?php
class Mail_SendController extends Promotor_Controller_Action {

	public $acl = array(
		'one' => 'send',
		'queue' => 'send',
	);

	public $ajaxable = array(
		'one' => array('json'),
		'queue' => array('json')
	);

	public function init() {
		/* @var $ajaxContext Zend_Controller_Action_Helper_AjaxContext */
		$ajaxContext = $this->_helper->getHelper('AjaxContext');
		$ajaxContext->initContext();
	}

	/**
	 * Wysyła pojedyńczy mail
	 * @todo ..
	 * @return void
	 */
	public function oneAction() {
		/* @var $rq Zend_Controller_Request_Http */
		$rq = $this->getRequest();
	}
	
	/**
	 * Wysyła pojedyńczy mail
	 * @return void
	 */
	public function queueAction() {
		/* @var $rq Zend_Controller_Request_Http */
		$rq = $this->getRequest();
		
		if (!$rq->isPost()) {
			$this->view->status = 'FAILURE';
			return;
		}
		
		$model = new Mail_Model_Send();
		$model->sendQueue($rq->getPost());

		$this->view->status = $model->getStatus();
		$this->view->messages = $model->getMessages();
	}
}